package com.sky.wsp.jar.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class CmdUtil {
  private static final Logger log = LoggerFactory.getLogger(CmdUtil.class);
  public CmdUtil() {
  }

  public static void callJarCmd(String targetJarName, String targetPath) {
    try {
      Process process = Runtime.getRuntime().exec("cmd /c jar cvfM0 " + targetJarName + " -C " + targetPath + " ./");
      final InputStream is1 = process.getInputStream();
      final InputStream is2 = process.getErrorStream();
      (new Thread() {
        public void run() {
          BufferedReader br1 = new BufferedReader(new InputStreamReader(is1));

          try {
            String line1 = null;

            while((line1 = br1.readLine()) != null) {
              if (line1 != null) {
              }
            }
          } catch (IOException var11) {
            var11.printStackTrace();
          } finally {
            try {
              is1.close();
            } catch (IOException var10) {
              var10.printStackTrace();
            }

          }

        }
      }).start();
      (new Thread() {
        public void run() {
          BufferedReader br2 = new BufferedReader(new InputStreamReader(is2));

          try {
            String line2 = null;

            while((line2 = br2.readLine()) != null) {
              if (line2 != null) {
              }
            }
          } catch (IOException var11) {
            var11.printStackTrace();
          } finally {
            try {
              is2.close();
            } catch (IOException var10) {
              var10.printStackTrace();
            }

          }

        }
      }).start();
      process.waitFor();
      process.destroy();
      log.info("Waiting process over.");
    } catch (IOException var5) {
      var5.printStackTrace();
    } catch (Exception var6) {
      var6.printStackTrace();
    }

  }
}